package com.example.ending_demo.servlet;

import com.example.ending_demo.dao.AddressDao;

import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/AddressDeleteServlet")
public class AddressDeleteServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Integer addr_id = Integer.valueOf(request.getParameter("id"));
		AddressDao dao = new AddressDao();
		dao.deleteAddress(addr_id);
		response.sendRedirect("AddressListPageServlet");
    }
}